/* 
 * File:        SpamIndicatorEquation.cpp
 * Author:      Cody TV Weber
 * Date:        March 19, 2014, 7:57 PM
 * Description: Contains the Spam Indicator Equation.
 */
#include "spamIndicatorEquation.h"
/*
 * double spamIndicatorEquation(double hamProbability, double spamProbability)-
 *              Takes the probabilities from the Entry containing the 
 *              probabilities of the word being occuring in a Spam emails and
 *              a ham emails and calculates an indication how high the
 *              probability is that the particular Entry would be indicated
 *              as a Spam.
 */
double spamIndicatorEquation(double hamProbability, double spamProbability) {
    if((hamProbability + spamProbability) == 0){
        return 0;
    }
    return (spamProbability / (hamProbability + spamProbability));
}

/*
 * double addingProbabilityToAMean(     double newOccuranceProbability, 
 *                                      double previousProbability, 
 *                                      int previousMeanDenomenator) - 
 *              Takes a new probability and adds it to a previous mean.
 */
double addingProbabilityToAMean(double newOccuranceProbability, double previousMean, int previousMeanDenomenator) {
    if((previousMeanDenomenator + 1) == 0 ){
        return 0;
    }
    return ((newOccuranceProbability + (previousMean * previousMeanDenomenator)) / (previousMeanDenomenator + 1));
}